//
//  ViewController.swift
//  swiftDemo
//
//  Created by mac on 2017/3/1.
//  Copyright © 2017年 毕小强. All rights reserved.
//

import UIKit
import Alamofire

var screenSize = UIScreen.main.bounds
var dataTable :UITableView!
var itemStringArr  = ["基础内容","基础运算符","字符串","集合类型","控制流","函数","闭包","枚举","类和结构体","属性","方法","下标","继承","初始化","反初始化","自动引用计数","可选链","错误处理","类型转换","内嵌类型","扩展","协议","泛型","访问控制","高级运算符"]


class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        self.view.backgroundColor = UIColor.white
        self.title = "首页"
        
        
        dataTable = UITableView.init(frame: CGRect(x: 0.0, y: 0, width: screenSize.width, height: screenSize.height), style: UITableViewStyle.plain)
        dataTable.delegate = self
        dataTable.dataSource = self
        dataTable.tableFooterView = UIView.init(frame: CGRect.zero)
        self.view.addSubview(dataTable)
        
        
        dataTable.setContentOffset(CGPoint(x: 0.0, y: 440.0), animated: true)
    }

    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return itemStringArr.count
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 44
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let identifier="identtifier"
        var cell = tableView.dequeueReusableCell(withIdentifier: identifier)
        if cell == nil {
            cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: identifier)
        }
        cell?.textLabel?.text = itemStringArr[indexPath.row]
        return cell!
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        switch indexPath.row {
        case 0:
            let bVC = baseVC()
            bVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(bVC, animated: true)
        case 1:
            let oVC = operatorVC()
            oVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(oVC, animated: true)
        case 2:
            let sVC = StringVC()
            sVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(sVC, animated: true)
        case 3:
            let aVC = aggregateVC()
            aVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(aVC, animated: true)
        case 4:
            let cVC = controllerFlowVC()
            cVC.mutableDic[1] = "one"
            cVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(cVC, animated: true)
        case 5:
            let fVC = functionVC()
            fVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(fVC, animated: true)
        case 6:
            let cVC = closureVC()
            cVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(cVC, animated: true)
        case 7:
            let eVC = EnumVC()
            eVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(eVC, animated: true)
        case 8:
            let ctVC = ClassWithTructVC()
            ctVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(ctVC, animated: true)
        case 9:
            let pVC = PropertyVC()
            pVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(pVC, animated: true)
        case 10:
            let mVC = MethodVC()
            mVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(mVC, animated: true)
        case 11:
            let sVC = SubscriptVC()
            sVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(sVC, animated: true)
        case 12:
            let iVC = InheritVC()
            iVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(iVC, animated: true)
        case 13:
            let iVC = Initialize()
            iVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(iVC, animated: true)
        case 14:
            let dVC = DeinitializeVC()
            dVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(dVC, animated: true)
        case 15:
            let aVC = ArcVC()
            aVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(aVC, animated: true)
        case 16:
            let oVC = OptionalchainVC()
            oVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(oVC, animated: true)
        case 17:
            let eVC = ErrorHandleVC()
            eVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(eVC, animated: true)
        case 18:
            let tVC = TypeTransformVC()
            tVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(tVC, animated: true)
        case 19:
            let nVC = NestVC()
            nVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(nVC, animated: true)
        case 20:
            let eVC = ExtensionVC()
            eVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(eVC, animated: true)
        case 21:
            let pVC = ProtocolVC()
            pVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(pVC, animated: true)
        case 22:
            let gVC = GenericityVC()
            gVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(gVC, animated: true)
        case 23:
            let vlVC = VisitLimitVC()
            vlVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(vlVC, animated: true)
        case 24:
            let sVC = SeniorOperatorVC()
            sVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(sVC, animated: true)
        default:
            print("还没有页面让你跳")
            let oVC = OCFileVC()
            oVC.title = itemStringArr[indexPath.row]
            self.navigationController?.pushViewController(oVC, animated: true)
        }
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

